package com.xiaoxi.bms.common.util;

import com.xiaoxi.bms.domain.user.BMSUserContext;
import lombok.extern.slf4j.Slf4j;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;

/**
 * @Author xiaoxi
 * @ProjectName springcloudbms
 * @PackageName common.util
 * @ClassName AuthUtils
 * @Description TODO
 * @Date 2023/2/2 10:46
 * @Version 1.0
 */
@Slf4j
public class AuthUtils {

    /**
     * 获取当前登录用户
     *
     * @return
     */
    public static BMSUserContext getCurrentUser() {
        return JwtTokenUtils.getUserToken(ContextUtils.getToken());
    }

    public static Authentication getAuthentication() {
        return SecurityContextHolder.getContext().getAuthentication();
    }

}
